<?php
namespace app\admin\controller;
use \think\Controller;
use \think\Session;
use \think\Db;
class Community extends Common
{
	public function index(){

		$result = Db::name('community')->order('community_id')->order('community_status')->select();
		$this->assign('communitylist',$result);
		return $this->fetch();
	}

	public function post(){

		$result = Db::name('post')->alias('a')->join('city b','a.city_id = b.city_id')->join('community c','a.community_id = c.community_id')->join('user d','a.user_id = d.user_id')->order('post_id')->select();
		$this->assign('postlist',$result);
		return $this->fetch();

	}

	public function postcomment(){
		if(input('postid')=='')
			$result = Db::name('postcomment')->alias('a')->join('post b','a.post_id = b.post_id')->join('user c','a.user_id = c.user_id')->order('comment_id')->select();
		else
			$result = Db::name('postcomment')->where('a.post_id',input('postid'))->alias('a')->join('post b','a.post_id = b.post_id')->join('user c','a.user_id = c.user_id')->order('comment_id')->select();
		$this->assign('postcommentlist',$result);
		return $this->fetch();

	}


	public function postreply(){

		$result = Db::name('postreply')->where('a.comment_id',input('commentid'))->alias('a')->join('postcomment b','a.comment_id = b.comment_id')->join('user c','a.user_id = c.user_id')->order('a.comment_id')->select();
		$this->assign('postreplylist',$result);
		$this->assign('commentid',input('commentid'));
		return $this->fetch();

	}

	
}